<?php

define('PAGE_SIZE', 10 );

function getPage($current,$total,$query=null){
	$page = array();
	$page['current'] = $current;
	$page['cnt'] = $total;
	$page['end'] = floor( $page['cnt'] / PAGE_SIZE );
	if( $page['cnt'] % PAGE_SIZE ) $page['end']++;
	$page['item'] = PAGE_SIZE;
	$paging = array();
	if( $page['end'] >= 15 ){
		$pagecnt = 0;
		for( $i = $page['current'] -7; $i <= $page['end']; $i++ ){
			if( $i > 0 ){
				$paging[] = $i;
				$pagecnt++;
			}
			if( $pagecnt >= 15 ) break;
		}
	
	}else{
		// 全15件以下の場合は全件表示
		for( $i = 1; $i <= $page['end']; $i++ ){
			$paging[] = $i;
		}
	}
	$page['paging'] = $paging;
	if( $query!=null ) $page['query'] = $query;
	return $page;
}